import Box from './Box'
export default class Rect extends Box{
    readonly name = 'Rect'
    shape: string = 'rect'
    public computePath(){
        let {width: w, height: h, borderWidth: bw, originX, originY, radius:r} = this.style
        this._out = [-originX, -originY, w, h]
        let min = Math.min(w/2, h/2)
        if(bw > 0){
            if(bw > min) bw = min
            this._in = [-originX + bw, -originY + bw, w - bw*2, h-bw*2]
        }
    }
    public draw(ctx:CanvasRenderingContext2D, path:number[]){
        if(!path || !path.length) return
        ctx.moveTo(path[0], path[1])
        ctx.lineTo(path[0]+path[2], path[1])
        ctx.lineTo(path[0]+path[2], path[1]+path[3])
        ctx.lineTo(path[0], path[1]+path[3])
        ctx.closePath()
    }
}